package cn.edu.ecnu.gis.client.gadgets;

import cn.edu.ecnu.gis.client.model.Gadget;
import cn.edu.ecnu.gis.client.model.GadgetClass;
import cn.edu.ecnu.gis.client.model.UserPref;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.ImageBundle;
import com.google.gwt.user.client.ui.Label;

public class HelloWorldGadget extends Gadget{
	
	public static class Class extends GadgetClass {
		public static UserPref text = new UserPref("Text","Hello World");
		public Class(){
			super("HelloWorld",true);
			addUserPref( text );
		}
		public Gadget newGadget(){
			return new HelloWorldGadget(this);
		}
	}
	
	private Label label = new Label();  
    protected HelloWorldGadget(Class c){
    	super(c);
    	initWidget( label );
    	setStyleName("HelloWorld");
    }
    
    public void refresh(){
    	label.setText( (String)getUserPrefValue(Class.text) );
    }
    public interface BoundImage extends ImageBundle {

        AbstractImagePrototype inbox();
    }

   
    public AbstractImagePrototype getBoundImage() {
        BoundImage images = (BoundImage) GWT.create(BoundImage.class);
        return images.inbox();
    }
}